using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace AirConnon
{
    public class PlayerController : MonoBehaviour
    {
        PlayerCharacter player;
        bool fireKeyPressed = false;

        void Start()
        {
            player = GetComponent<PlayerCharacter>();
        }

        void Update()
        {
            float x = Input.GetAxis("Horizontal");
            float z = Input.GetAxis("Vertical");
            player.Move(x, z);
            if (Input.GetButtonDown("Jump"))
            {
                player.Jump(player.jumpSpeed);
            }
            if (Input.GetKeyDown(KeyCode.J))
            {
                player.airCannonWeapon.Fire();
            }
            //Pressed to Fire
            /*if (Input.GetKey(KeyCode.J))
            {
                if (!fireKeyPressed)
                {
                    player.airCannonWeapon.Fire();
                    fireKeyPressed = true;
                }
            }
            if (Input.GetKeyUp(KeyCode.J))
            {
                player.airCannonWeapon.DestroyCannon();
                fireKeyPressed = false;
            }*/


            if (Input.GetKeyDown(KeyCode.K))
            {
                player.airCannonWeapon.SwitchCannonLevel();
            }
        }
    }

}
